import { cardCache, toast } from 'nc-lightapp-front';
import config from '../config';
const { setDefData } = cardCache;

export default function (node) {
    // const checkedRows = props.table.getCheckedRows(moduleId);
    // if (checkedRows.length === 1) {
    //     props.button.setButtonDisabled(['more'], false);
    //     const record = checkedRows[0].data.values;
    //     if (record.src_type.value === '0') {
    //         if (record.billstatus.value === '0') {
    //             props.button.setButtonDisabled(['approve_group'], true);
    //             props.button.setButtonDisabled(['edit', 'delete'], false);
    //         } else if (record.billstatus.value === '1') {
    //             props.button.setButtonDisabled(['unapprove'], true);
    //             props.button.setButtonDisabled(['edit', 'delete', 'approve_group', 'approve'], false);
    //         } else if (record.billstatus.value === '3') {
    //             props.button.setButtonDisabled(['edit', 'delete', 'approve'], true);
    //             props.button.setButtonDisabled(['approve_group', 'unapprove'], false);
    //         }
    //     } else {
    //         props.button.setButtonDisabled(['edit', 'delete', 'approve_group'], true);
    //     }
    // } else {
    //     props.button.setButtonDisabled(['more', 'edit', 'delete', 'approve_group'], true);
    // }
    // // else {
    // //     props.button.setButtonDisabled(['edit', 'more'], true);
    // //     props.button.setButtonDisabled(['delete', 'approve_group'], false);
    // // }
    if (!node || !node.beanid) return;
    const props = this.props;
    const meta = props.meta.getMeta();
    const ref = meta[config.bodycode].items.find((item) => {
        return item.attrcode === 'qry_objdatatype';
    });

    ref.refcode = 'uap/refer/riart/mdTreeByIdRef/index.js';
    ref.itemtype = 'refer';
    ref.fieldDisplayed = 'refname';
    ref.fieldValued = 'refpk';
    ref.queryCondition = () => {
        return { beanId: node.beanid, TreeRefActionExt: '' };
    };

    props.meta.setMeta(meta);
    this.loadData(node);
}
